package com.lujianfei.filesend.widget

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.databinding.BindingAdapter
import com.lujianfei.filesend.base.BaseView
import com.lujianfei.filesend.databinding.WidgetBottomTabBinding


/**
 * Author: lujianfei
 * Date: 2023/11/1 9:50
 * Description: 底部Tab
 */

class BottomTab(context: Context, attrs: AttributeSet? = null) : BaseView(context, attrs) {

    private var binding:WidgetBottomTabBinding ?= null

    var text:String = ""
        set(value) {
            binding?.text = value
            field = value
        }

    var tabSelected:Boolean = false
        set(value) {
            binding?.selected = value
            field = value
        }
    init {
        binding = WidgetBottomTabBinding.inflate(LayoutInflater.from(context), this, true)
    }
}

@BindingAdapter(value = ["BottomTab_text","BottomTab_selected"], requireAll = false)
fun BottomTab_binding(view:BottomTab, text:String, selected:Boolean) {
    view.text = text
    view.tabSelected = selected
}